package cn.fl.project.service.impl;

import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.project.service.IPrjPayInfoForSmallLoanService;
import org.springframework.stereotype.Service;

@Service("prjPayInfoForSmallLoanService")
public class PrjPayInfoForSmallLoanServiceImpl implements IPrjPayInfoForSmallLoanService {
    /**
     * 计算专享额度接口
     *
     * @param cstLevel    客户信用风险等级
     * @param splLevel    经销商星级
     * @param totLsItmAmt 设备金额
     * @param firstPayPct 首付比例
     * @return
     */
    @Override
    public Double calculateSmallAmt(String cstLevel, String splLevel, Double totLsItmAmt, Double firstPayPct) {
        if(StringUtils.isBlank(cstLevel) || StringUtils.isBlank(splLevel)){
            return 0d ;
        }
        Double ratio = 0d;
        if (cstLevel.equals("4")){
            ratio = 0.13 ;
        }else if(cstLevel.equals("5")){
            if (Integer.valueOf(splLevel)>30){
                ratio = 0.13 ;
            }
            if (Integer.valueOf(splLevel)<40){
                ratio = 0.06 ;
            }
        }else if (cstLevel.equals("1")){
            if (Integer.valueOf(splLevel)>40){
                ratio = 0.13 ;
            }
            if (Integer.valueOf(splLevel)<50){
                return 0d ;
            }
        }else{
            return 0d;
        }
        return totLsItmAmt * ratio * (1-firstPayPct/100);
    }
}
